package com.gxa.saas.service.impl;

import com.gxa.saas.mapper.PurchaseMapper;
import com.gxa.saas.mapper.StorageMapper;
import com.gxa.saas.pojo.Purchase;
import com.gxa.saas.pojo.Storage;
import com.gxa.saas.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author wxz
 */
@Service
public class PurchaseServiceImpl implements PurchaseService {

    @Autowired
    PurchaseMapper purchaseMapper;
    @Autowired
    PurchaseService purchaseService;
    @Autowired
    StorageMapper storageMapper;


    @Override
    public List<Purchase> selectByPage(Integer offset, Integer size) {
        return purchaseMapper.selectByPage(offset,size);
    }




    @Override
    public Integer deleteById(Integer id) {
        return purchaseMapper.deleteById(id);
    }

    @Override
    public List<Purchase> selectAll() {
        return purchaseMapper.selectAll();
    }

    @Override
    public Integer updateStatus(Integer id, String status) {
        Purchase purchase = new Purchase();
        if (purchase.getOperate().equals("审批")) {
            if (purchase.getStatus().equals("同意")) {
                return purchaseService.updateStatus(id, "已通过");
            } else if (purchase.getStatus().equals("不同意")) {
                return purchaseService.updateStatus(id, "不通过");
            }
            if (purchase.getOperate().equals("入库")) {
                if (purchase.getStatus().equals("同意")) {
                    return purchaseService.updateStatus(id, "已入库");
                }
            }
        }
        return purchaseService.updateStatus(id, status);
    }




    @Override
    public List<Purchase> selectByName(Map map) {
        return purchaseMapper.selectByName(map);
    }


//    @Override
//    public List<Purchase> selectBySupplier(String supplier) {
//        //return purchaseMapper.selectBySupplier(supplier);
//        return null;
//    }
//
//    @Override
//    public List<Purchase> selectByStatus(String status) {
//       // return purchaseMapper.selectByStatus(status);
//        return null;
//    }


//    @Override
//    public List<Purchase> selectBypayType(String payType) {
//        //return purchaseMapper.selectBypayType(payType);
//        return null;
//    }

//    @Override
//    public List<Purchase> selectByApprover(String approver) {
//       // return purchaseMapper.selectByApprover(approver);
//        return null;
//    }
//
//    @Override
//    public List<Purchase> selectBycreateDate(String date) {
//        //return purchaseMapper.selectBycreateDate(date);
//        return null;
//    }
//
//    @Override
//    public List<Purchase> selectByNeedDate(String date) {
//       // return purchaseMapper.selectByNeedDate(date);
//        return null;
//    }


}
